package com.laboratory.serviceprovide.setting.service.impl;

import com.Laboratory.setting.service._equipmentService;
import com.Laboratory.util.completionUtil;
import com.Laboratory.utilPojo.equipmentWithRoomNo;
import com.Laboratory.workBench.pojo.equipment;
import com.laboratory.serviceprovide.workBench.mapper.equipmentMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Author acok
 * @description:TODO
 * @Date 2023/1/3 10:03
 * @Version 1.0
 */
@DubboService(interfaceClass = _equipmentService.class,version = "1.0.0")
public class _equipmentServiceImpl implements _equipmentService {
    @Resource
    private equipmentMapper equipmentMapper;


    @Override
    public List<equipmentWithRoomNo> getEquipmentByCondition(Map<String, Object> map) {
        return equipmentMapper.getEquipmentByCondition(map);
    }

    @Override
    public int getEquipmentRowsByCondition(Map<String, Object> map) {
        return equipmentMapper.getEquipmentRowsByCondition(map);
    }

    @Override
    public int insertEquipment(equipment equipment) {
        //获取序号
        List<String> list = equipmentMapper.getEquipmentNoArray(equipment.getRoomid());
        String [] arr=new String[list.size()];
        for (int i=0;i<list.size();i++){
            arr[i]=list.get(i);
        }
        System.out.println(Arrays.toString(arr));
        String equipmentNo= completionUtil.autoCompletionEquipmentNo(arr);
        System.out.println("--->"+equipmentNo);
        equipment.setEquno(equipmentNo);
        return equipmentMapper.insertEquipment(equipment);
    }

    @Override
    public int updateEquipmentById(equipment equipment) {
        return equipmentMapper.updateEquipmentById(equipment);
    }

    @Override
    public int deleteEquipmentByIds(String[] ids) {
        return equipmentMapper.deleteEquipmentByIds(ids);
    }

    @Override
    public int updateEquipmentStateByOverTime(String nowTime) {
        return equipmentMapper.updateEquipmentStateByOverTime(nowTime);
    }
}
